package com.ruoyi.web.controller.wb;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.wb.domain.WbEntAuth;
import com.ruoyi.wb.service.IWbEntAuthService;
import com.ruoyi.wb.vo.WbEntAuthVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 企业认证Controller
 *
 * @author ruoyi
 * @date 2024-10-14
 */

@Api(tags="企业认证信息管理")
@RestController
@RequestMapping("/wb/wbEntAuth")
public class WbEntAuthController extends BaseController {
    @Autowired
    private IWbEntAuthService wbEntAuthService;

    /**
     * 查询企业认证列表
     */
    @ApiOperation("查询企业认证列表")
    @GetMapping("/list")
    public TableDataInfo list(WbEntAuth wbEntAuth) {
        startPage();
        List<WbEntAuth> list = wbEntAuthService.selectWbEntAuthList(wbEntAuth);
        return getDataTable(list);
    }

    /**
     * 导出企业认证列表
     */
    @ApiOperation("导出企业认证列表")
    @Log(title = "企业认证", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WbEntAuth wbEntAuth) {
        List<WbEntAuth> list = wbEntAuthService.selectWbEntAuthList(wbEntAuth);
        ExcelUtil<WbEntAuth> util = new ExcelUtil<WbEntAuth>(WbEntAuth.class);
        util.exportExcel(response, list, "企业认证数据");
    }

    /**
     * 获取企业认证详细信息
     */
    @ApiOperation("获取企业认证详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(wbEntAuthService.selectWbEntAuthById(id));
    }

    /**
     * 新增企业认证
     */
    @ApiOperation("新增企业认证")
    @Log(title = "企业认证", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WbEntAuth wbEntAuth) {
        return toAjax(wbEntAuthService.insertWbEntAuth(wbEntAuth));
    }

    /**
     * 修改企业认证
     */
    @ApiOperation("修改企业认证")
    @Log(title = "企业认证", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WbEntAuth wbEntAuth) {
        return toAjax(wbEntAuthService.updateWbEntAuth(wbEntAuth));
    }

    /**
     * 删除企业认证
     */
    @ApiOperation("删除企业认证")
    @Log(title = "企业认证", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(wbEntAuthService.deleteWbEntAuthByIds(ids));
    }

    /**
     * 查询企业认证列表
     */
    @ApiOperation("查询企业认证列表带维保公司")
    @GetMapping("/listEntAuthWb")
    public TableDataInfo listEntAuthWb(WbEntAuth wbEntAuth) {
        List<WbEntAuthVo> list = wbEntAuthService.listEntAuthWb(wbEntAuth);
        return getDataTable(list);
    }

}